using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using Microsoft.Practices.RepositoryFactory.Converters;

namespace Microsoft.Practices.RepositoryFactory.CodeGeneration.ObjectModel
{
    /// <summary/>
    public class Property : IComparable<Property>
    {
        #region Property properties
        private string name;

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        /// <value>The name.</value>
        [TypeConverter(typeof(CSharpIdentifierConverter))]
        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        private bool isNullable;

        /// <summary>
        /// Gets or sets a value indicating whether this instance is nullable.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance is nullable; otherwise, <c>false</c>.
        /// </value>
        [ReadOnly(true)]
        public bool IsNullable
        {
            get { return isNullable; }
            set { isNullable = value; }
        }

        private Type type;

        /// <summary>
        /// Gets or sets the type.
        /// </summary>
        /// <value>The type.</value>
        [ReadOnly(true)]
        public Type Type
        {
            get { return type; }
            set { type = value; }
        }
        #endregion

        #region TableMappings
        private string columnName;
        /// <summary>
        /// Gets or sets the name of the column.
        /// </summary>
        /// <value>The name of the column.</value>
        [Browsable(false)]
        public string ColumnName
        {
            get { return columnName; }
            set { columnName = value; }
        }

        private bool isPrimaryKey = false;

        /// <summary>
        /// Gets or sets a value indicating whether this instance is primary key.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance is primary key; otherwise, <c>false</c>.
        /// </value>

        [Browsable(false)]
        public bool IsPrimaryKey
        {
            get { return isPrimaryKey; }
            set { isPrimaryKey = value; }
        }

        private bool readOnly = false;

        public bool ReadOnly
        {
            get { return readOnly; }
            set { readOnly = value; }
        }
        #endregion

        #region IComparable<Property> Members

        /// <summary>
        /// Uses the Name property as a basis for comparison.
        /// </summary>
        /// <param name="other">A <see cref="Property"/></param>
        /// <returns>An integer.</returns>
        public int CompareTo(Property other)
        {
           return this.Name.CompareTo(other.Name);
        }

        #endregion
     }
}
